//测试
var business = {};

//获取图层样式
business.getStyle = function (feature) {
    //着色
    var fillColor = null;
    var opacity = 1;
    var fillOpacity = 1;
    switch (feature.properties.NAME) {
        case '银川市':
            fillColor = 'red';
            break;
        case '吴忠市':
            fillColor = 'blue'
            break;
        case '中卫市':
            fillColor = 'green'
            break;
        case '固原市':
            fillColor = 'yellow'
            break;
        case '石嘴山市':
            fillColor = '#0000ff'
            break;
        default:
            opacity = 0;
            break;
    }

    var style = {
        fill: true,//是否填充色
        fillColor: fillColor,//填充色 eg '#0000ff','red'
        opacity: opacity,//边框颜色透明度
        stroke: false,//是否有边框颜色
        fillOpacity: fillOpacity//填充色透明度
    }

    return style;
}

//获取点icon
business.getPointIcon = function (feature) {
    let divIcon = L.divIcon({
        html: '<img src="../sources/icon/sun_32x32.png" style="vertical-align: middle;">' + feature.properties.NAME,
        // iconSize: 12,
        className: 'test',//icon 样式类
    })

    // let icon = L.icon({
    //     iconUrl: "../sources/icon/sun_32x32.png",
    //     iconSize: [28, 28],
    //     shadowUrl: "../sources/icon/sun1.png",
    //     shadowSize: [32, 32],
    // })
    return divIcon
}

//创建标注
business.createMarker = function (feature, latlng) {
    //标注样式
    var marker = L.marker(latlng, { icon: business.getPointIcon(feature) });
    //标注点击事件
    marker.on('click', function (e) {
        alert(feature.properties.NAME + '  这是marker点击事件');
    })

    return marker;
}

//每个元素添加事件
business.onEachFeature_districtLayer = function (feature, layer) {
    //图层点击事件
    layer.on('click', function (e) {
        alert(feature.properties.NAME);
    })
}
